﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Drawing;
using ZoneFiveSoftware.Common.Visuals;
using ZoneFiveSoftware.Common.Visuals.Fitness;
using ZoneFiveSoftware.Common.Data.Fitness;
using System.Windows.Forms;
using HermesPlugin.Properties;
using System.IO;

namespace HermesPlugin.Export
{
    public class ExtendEditActivity : IAction
    {
        private IList<IActivity> _activities = null;

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        public ExtendEditActivity(IList<IActivity> activities)
        {
            _activities = activities;
        }

        public bool Enabled
        {
            get { return true; }
        }

        public bool HasMenuArrow
        {
            get { return true; }
        }

        public Image Image
        {
            get
            {
                return Resources.Image_TCXExport;
            }
        }

        public void Refresh()
        {
            throw new NotImplementedException();
        }

        public string Title
        {
            get { return "Export"; }
        }

        public void Run(Rectangle rectButton)
        {
            foreach (IActivity activity in _activities)
            {
                SaveFileDialog saveFiles = new SaveFileDialog();
                saveFiles.Filter = "Garmin TCX Files | *.tcx";
                saveFiles.DefaultExt = "tcx";
                if (saveFiles.ShowDialog() == DialogResult.OK )
                {
                    FileInfo fileNFO = new FileInfo(saveFiles.FileName);
                    if ( fileNFO.Extension.ToLower() == ".tcx" )
                        ExportTCX.ExportActivity(activity, fileNFO.FullName);
                }
            }
        }
    }
}
